package chat.mp3s.mcp.service;

import java.util.List;

import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Service;

import chat.mp3s.mcp.domain.AppProperties;
import chat.mp3s.mcp.entity.SalesInfo;
import chat.mp3s.mcp.mapper.DBViewMapper;
import chat.mp3s.mcp.utils.SpringUtils;
import jakarta.annotation.Resource;

@Service
public class DBViewMapperService {
    @Resource
    private AppProperties appProperties;

    @Tool(name = "getSalesRank", description = """
        在数据库中查询销量排名，以日期为参数传入，返回销量、销售排名信息。
        """)
    public String getSalesRank(String date) {

        // 通过SpringUtils获取DBViewMapper的实例
        List<SalesInfo> salesinfo = SpringUtils.getBean(DBViewMapper.class).getSalesRank(date);

        // 将查询结果转换为字符串并返回
        return salesinfo.toString();
    }
}
